set more off
set matsize 800

log using may06_fourcohorts_edcdf_1990_cluster.log, replace

use prdescent2005
keep if yob >= 1924 & yob <= 1963
gen old = yob > 1923 & yob <= 1933
gen young = yob > 1933 & yob <= 1943
gen veryyoung = yob > 1943 & yob <= 1953
gen superyoung = yob > 1953 & yob <= 1963
* keep if age >= 21

drop if cenyr == 1970
drop if cenyr == 1980
keep if bornpr

sort yob yrssch
merge yob yrssch using fake_treat_4463
drop if _merge == 2


replace yrssch_1990 = yrssch if cenyr == 1990 & liveinus

gen yrssch_all = .
replace yrssch_all = yrssch_1990 if cenyr == 1990
replace yrssch_all = 0 if yrssch == 0 & cenyr == 1980
replace yrssch_all = 3 if (yrssch >= 1 & yrssch <= 4) & cenyr == 1980
replace yrssch_all = 7 if (yrssch >= 5 & yrssch <= 8) & cenyr == 1980
replace yrssch_all = yrssch if (yrssch >= 9 & yrssch <= 12) & cenyr == 1980
replace yrssch_all = 14 if (yrssch >= 13 & yrssch <= 15) & cenyr == 1980
replace yrssch_all = yrssch if yrssch == 16 & cenyr == 1980
replace yrssch_all = 18 if yrssch > 16 

gen groupid = yob*100 + yrssch_all 

drop _merge
sort yob yrssch_all
merge yob yrssch_all using cdfedless_1990
drop if _merge == 2
gen cdfedlesssq = cdfedless^2

gen treat = actual_treat

gen roundtreat = round(actual_treat,1)

gen dtreat1 = roundtreat==1
gen dtreat2 = roundtreat==2
gen dtreat3 = roundtreat==3
gen dtreat4 = roundtreat==4
gen dtreat5 = roundtreat==5
gen dtreat6 = roundtreat==6
gen dtreat7 = roundtreat==7
gen dtreat8 = roundtreat==8


gen faketreat = actual_treat
replace faketreat = fake_treat if veryyoung
gen roundfaketreat = round(faketreat,1)

gen dfaketreat1 = roundfaketreat ==1
gen dfaketreat2 = roundfaketreat ==2
gen dfaketreat3 = roundfaketreat ==3
gen dfaketreat4 = roundfaketreat ==4
gen dfaketreat5 = roundfaketreat ==5
gen dfaketreat6 = roundfaketreat ==6
gen dfaketreat7 = roundfaketreat ==7
gen dfaketreat8 = roundfaketreat ==8

gen potex = age-yrssch-6
gen potexsq = potex^2

gen yy = (veryyoung | superyoung)
gen yypotex = yy*potex
gen yypotexsq = yy*potexsq

gen agesq = age^2

/*
gen yyage = yy*age
gen yyagesq = yy*agesq
*/

tab age, gen(dage)
drop dage1

gen yyage = yy*age
tab yyage, gen(yydage)
drop yydage1

gen dummy1990 = cenyr == 1990
gen yydummy1990 = yy*dummy1990


gen yyfemale = yy*female


* global ageexp "age agesq potex potexsq"
* global ageexp "dage* potex potexsq dummy1990"

tab yob, gen(dyob)
drop dyob1

tab yrssch_all, gen(deduc)
drop deduc1 

gen yyyrssch_all = yrssch_all*yy
tab yyyrssch_all, gen(yydeduc)
drop yydeduc1 


reg speakeng dtreat* dfaketreat* dyob* deduc* yydeduc* potex* yypotex* dage* yydage* dummy1990 yydummy1990 female yyfemale , cluster(groupid)
testparm dtreat1-dtreat8

reg speakeng dtreat* dfaketreat* dyob* deduc* yydeduc* potex* yypotex* dage* yydage* dummy1990 yydummy1990 female yyfemale  cdfed*, cluster(groupid)
testparm dtreat1-dtreat8

reg engwell dtreat* dfaketreat* dyob* deduc* yydeduc* potex* yypotex* dage* yydage* dummy1990 yydummy1990 female yyfemale  , cluster(groupid)
testparm dtreat1-dtreat8

reg engwell dtreat* dfaketreat* dyob* deduc* yydeduc* potex* yypotex* dage* yydage* dummy1990 yydummy1990 female yyfemale  cdfed*, cluster(groupid)
testparm dtreat1-dtreat8

reg speakeng dtreat* dfaketreat* dyob* deduc* yydeduc* potex* yypotex* dage* yydage* dummy1990 yydummy1990 female yyfemale liveinus cdfed*, cluster(groupid)
testparm dtreat1-dtreat8

reg engwell dtreat* dfaketreat* dyob* deduc* yydeduc* potex* yypotex* dage* yydage* dummy1990 yydummy1990 female yyfemale liveinus cdfed*, cluster(groupid)
testparm dtreat1-dtreat8

* linear models
sum treat
sum treat if treat > 0
reg speakeng treat faketreat dyob* deduc* yydeduc* potex* yypotex* dage* yydage* dummy1990 yydummy1990 female yyfemale cdfed*, cluster(groupid)

reg speakeng treat faketreat dyob* deduc* yydeduc* potex* yypotex* dage* yydage* dummy1990 yydummy1990 female yyfemale , cluster(groupid)

reg engwell treat faketreat dyob* deduc* yydeduc* potex* yypotex* dage* yydage* dummy1990 yydummy1990 female yyfemale cdfed*, cluster(groupid)

reg engwell treat faketreat dyob* deduc* yydeduc* potex* yypotex* dage* yydage* dummy1990 yydummy1990 female yyfemale , cluster(groupid)

reg speakeng treat faketreat dyob* deduc* yydeduc* potex* yypotex* dage* yydage* dummy1990 yydummy1990 female yyfemale liveinus cdfed*, cluster(groupid)

reg speakeng treat faketreat dyob* deduc* yydeduc* potex* yypotex* dage* yydage* dummy1990 yydummy1990 female yyfemale liveinus , cluster(groupid)

reg engwell treat faketreat dyob* deduc* yydeduc* potex* yypotex* dage* yydage* dummy1990 yydummy1990 female yyfemale liveinus cdfed*, cluster(groupid)

reg engwell treat faketreat dyob* deduc* yydeduc* potex* yypotex* dage* yydage* dummy1990 yydummy1990 female yyfemale liveinus , cluster(groupid)

keep if ~liveinus


reg speakeng dtreat* dfaketreat* dyob* deduc* yydeduc* potex* yypotex* dage* yydage* dummy1990 yydummy1990 female yyfemale , cluster(groupid)
testparm dtreat1-dtreat8

reg speakeng dtreat* dfaketreat* dyob* deduc* yydeduc* potex* yypotex* dage* yydage* dummy1990 yydummy1990 female yyfemale  cdfed*, cluster(groupid)
testparm dtreat1-dtreat8

reg engwell dtreat* dfaketreat* dyob* deduc* yydeduc* potex* yypotex* dage* yydage* dummy1990 yydummy1990 female yyfemale  , cluster(groupid)
testparm dtreat1-dtreat8

reg engwell dtreat* dfaketreat* dyob* deduc* yydeduc* potex* yypotex* dage* yydage* dummy1990 yydummy1990 female yyfemale  cdfed*, cluster(groupid)
testparm dtreat1-dtreat8


* linear models
sum treat
sum treat if treat > 0
reg speakeng treat faketreat dyob* deduc* yydeduc* potex* yypotex* dage* yydage* dummy1990 yydummy1990 female yyfemale , cluster(groupid)

reg speakeng treat faketreat dyob* deduc* yydeduc* potex* yypotex* dage* yydage* dummy1990 yydummy1990 female yyfemale cdfed*, cluster(groupid)


reg engwell treat faketreat dyob* deduc* yydeduc* potex* yypotex* dage* yydage* dummy1990 yydummy1990 female yyfemale cdfed*, cluster(groupid)

reg engwell treat faketreat dyob* deduc* yydeduc* potex* yypotex* dage* yydage* dummy1990 yydummy1990 female yyfemale , cluster(groupid)


log close




